package com.pretty.test.controller.pets.message;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pretty.test.controller.pets.message.dto.MessagePageDTO;
import com.pretty.test.controller.pets.message.vo.MessagePageVO;
import com.pretty.test.entity.PetsMessage;
import com.pretty.test.service.IPetsMessageService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 用户反馈控制器
 * @author dujianyu
 * @since 2021-04-09
 */
@RestController
@AllArgsConstructor
@RequestMapping("/message")
public class PetsMessageController {

    private IPetsMessageService service;

    /**
     * 自定义分页
     * @param page
     * @param dto
     */
    @GetMapping("/page")
    public R<IPage<MessagePageVO>> page(Page<PetsMessage> page, MessagePageDTO dto){
        return R.ok(service.selectMessagePage(page,dto));
    }

    /**
     * 新增或修改
     * @param petsMessage
     */
    @PostMapping("/submit")
    public  R<Boolean> submit(@RequestBody PetsMessage petsMessage){
        return R.ok(service.saveOrUpdate(petsMessage));
    }

    /**
     * 逻辑删除
     * @param id
     */
    @PostMapping("/delete")
    public R<Boolean> delete(String id){
        return R.ok(service.removeById(id));
    }
}
